how to work out intervals